<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title></title>
    <link href="css/commons.css" type=text/css  rel="stylesheet">

</head>
<body onselectstart="return false">
<div class="mall-top clearfix">
    <div class="mall-close" data-log="payUIClose" data-into="2"  id="payUIClose">

    </div>
</div>
<div class="mall">

    <div class="jihuo-logo jihuo-logo2">
        <img src="images/logo_in.png">
    </div>
    <div class="jihuo-center">
        <h4 class="jihuo-title2" id="mm">获取Office密钥</h4>
    </div>
    <div class="pay-center">
        <div class="clearfix">
            <div class="office-family office-tab" data-id="1"  data-text="bb6d01050605000fba16597e6dc5ae28" data-log="office365_family">

            </div>
            <div class="office-person office-tab" data-id="2" data-text="02804067beae3da1faa4ff72edf33f20" data-log="office365_personal">

            </div>
        </div>
        <div class="tab-show" id="item-1">
            <div class="pay-article-detail clearfix">
                <div class="pay-detail">
                    <img src="images/advantage_365home.png">
                    <span  class="family_all detail_all" data-log="office365_familyDetail" id="family_all">了解详情</span>
                </div>
                <div class="pay-bottom">
                    <div class="pay-bottom-left"  id="pay-bottom-left">

                    </div>
                    <img src="images/pay_alibaba_wechat.png" class="pay_ali">
                    <img src="images/icon.png" class="pay-icon">
                    <img src="images/btn_loading_pic.png" class="pay-ewm">
                    <div class="pay-bottom-title">
                        <p><span class="span1">支付后，密钥将展示在自动跳转后的订单页面</span></p>
                        <p><span class="span2">[提示]软件激活秘钥属于数字化产品，一经售出，不予退换</span></p>
                    </div>
                </div>
            </div>

        </div>
        <div class="tab-show" id="item-2">
            <div class="pay-article-detail clearfix">
                <div class="pay-detail">
                    <img src="images/advantage_365personal.png">
                    <span  class="personal_all detail_all" data-log="office365_personalDetail" id="personal_all">了解详情</span>
                </div>
                <div class="pay-bottom">
                    <div class="pay-bottom-left" id="pay-bottom-left2">

                    </div>
                    <img src="images/pay_alibaba_wechat.png" class="pay_ali">
                    <img src="images/icon.png" class="pay-icon">
                    <img src="images/btn_loading_pic.png" class="pay-ewm">
                    <div class="pay-bottom-title">
                        <p><span class="span1">支付后，密钥将展示在自动跳转后的订单页面</span></p>
                        <p><span class="span2">[提示]软件激活秘钥属于数字化产品，一经售出，不予退换</span></p>
                    </div>
                </div>
            </div>
        </div>
        <div class="kefu logclick" data-log="customerServiceClick"  id="kefu">
            <img src="images/kefu.png">
        </div>
    </div>
    <div class="layer layer1 clearfix">
           <div class="lay-close ">
               <img src="images/icon_close_default.png" class="btnclose">
           </div>
            <div class="layer-btn">
                <button class="btns btn-no " id="btn-no" data-log="payUIClose">放弃(G)</button>
                <button class="btns btn-yes btnclose">激活(A)</button>
            </div>
    </div>
</div>
    <input type="hidden" name="payUI" value="payUI" id="fagepage">
     <script src="js/jquery.min.js"></script>
     <script>
        var loginStatus='http://officeplus.zhuazi.com/office/Weixin/loginStatus';
        var queryOrder_new='http://officeplus.zhuazi.com/office/order/queryOrder_new';
        var qrcode='http://officeplus.zhuazi.com/office/pay/qrcode';
        var log='http://officeplus.zhuazi.com/office/log/log/';
         var token;
         var channel;
         var edition;
         var sys;
         var cpuid;
         var main;
         var product_token='bb6d01050605000fba16597e6dc5ae28';

         window.onload=function (){
           window.external.GetPayMsg();
         };
         function getPaySys (obj,obj2,obj3,obj4,obj5){
             token=obj;
             channel=obj2;
             edition=obj3;
             sys=obj4;
             cpuid=obj5;
             main=$("#fagepage").val();
             tab(main,true);
             ewm();
         }

         $(function(){
             $(".pay-center  .office-tab").click(function () {
                 var id = $(this).attr("data-id");
                 product_token=$(this).attr("data-text");
                 $(".pay-ewm").hide();
                 var tablog=$(this).attr("data-log");
                 tab(tablog,true);
                 if(id > 0){
                     $('.tab-show').css('display','none');
                     $("#item-" + id).css('display','block');
                     clearInterval(interval2);
                     clearTimeout(time);
                     ewm (product_token)
                 }
                 if($(this).hasClass("office-person")){
                     $(this).removeClass('active-personal-out');
                     $(this).addClass('active-personal');
                     $(this).siblings().removeClass('active-family');
                     $(this).siblings().addClass('active-family-out');
                 }else if($(this).hasClass("office-family")){
                     $(this).removeClass('active-family-out');
                     $(this).addClass('active-family');
                     $(this).siblings().removeClass('active-personal');
                     $(this).siblings().addClass('active-personal-out');
                 }else{

                 }
             });
         });
         /*切换日志*/
         function Ajax(type, url, data, success, failed){
             // 创建ajax对象
             var xhr = null;
             if(window.XMLHttpRequest){
                 xhr = new XMLHttpRequest();
             } else {
                 xhr = new ActiveXObject('Microsoft.XMLHTTP')
             }

             var type = type.toUpperCase();
             // 用于清除缓存
             var random = Math.random();

             if(typeof data == 'object'){
                 var str = '';
                 for(var key in data){
                     str += key+'='+data[key]+'&';
                 }
                 data = str.replace(/&$/, '');
             }

             if(type == 'GET'){
                 if(data){
                     xhr.open('GET', url + '?' + data, true);
                 } else {
                     xhr.open('GET', url + '?t=' + random, true);
                 }
                 xhr.send();

             } else if(type == 'POST'){
                 xhr.open('POST', url, true);
                 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                 xhr.send(data);
             }

             // 处理返回数据
             xhr.onreadystatechange = function(){
                 if(xhr.readyState == 4){
                     if(xhr.status == 200){
                         success(xhr.responseText);
                     } else {
                         if(failed){
                             failed(xhr.status);
                         }
                     }
                 }
             }
         }
         var interval2;
         function ewm (ewm){
             var sendData = {
                 token:token,
                 product_token:product_token,
                 channel:channel,
                 buy_position:'downloader'
             };
             var get=Ajax('post',qrcode , sendData, function(data) {
                 var jsons = data;
                 var res;
                 if (typeof(JSON) == 'undefined') {
                     res = eval("(" + jsons + ")");
                 } else {
                     res = JSON.parse(jsons);
                 }
                 if (res.code == 200) {

                     var login_ewm = document.getElementById("pay-bottom-left");
                     var login_ewm2 = document.getElementById("pay-bottom-left2");
                     if(login_ewm.hasChildNodes())
                     {
                         login_ewm.removeChild(login_ewm.firstChild);
                     };
                     if(login_ewm2.hasChildNodes())
                     {
                         login_ewm2.removeChild(login_ewm2.firstChild);
                     };
                     var img = document.createElement("img");
                     var img2 = document.createElement("img");
                     img.setAttribute("id", "newImg");
                     img.src = res.data.url;
                     img2.src = res.data.url;
                     login_ewm.appendChild(img);
                     login_ewm2.appendChild(img2);
                     clearTimeout(time);
                     countdown=900;
                     settime();
                     pay();
                 }
             })
         };
        function getSuccess (){
            window.external.PaySuccess('success');
        }
         function pay(){
                 var logodata={
                     token:token
                 };
                 interval2 = setInterval(function () {
                     Ajax('post',queryOrder_new , logodata, function(data){
                         var jsons = data;
                         var res;
                         if (typeof(JSON) == 'undefined'){
                             res = eval("("+jsons+")");
                         }else {
                             res = JSON.parse(jsons);
                         }
                         if(res.code==200){

                             if(res.data.product_title == 'office365_family'){
                                 tab('officeFamily_wechat',false)
                             }else if(res.data.product_title == 'office365_personal'){
                                 tab('officePersonal_wechat',false)
                             }else{

                             }
//                             window.location.href="key.html";
                             clearInterval(interval2);
                             getSuccess ();
                         }

                     }, function(error){

                     });
                 },2000)
         }
         /*二维码过期*/
         var countdown=900;
         var time;
         function settime() {
             if (countdown == 0) {
                 countdown = 900;
                 $(".pay-ewm").show();
                 clearInterval(interval2);
             } else {
                 countdown--;

                 time=setTimeout(function() {
                     settime();
                 },1000)
             }

         }

         /*重新请求二维码*/
         $(".pay-ewm").click(function (){
             $(this).hide();
             ewm(product_token);
         });
         var payUIClose = document.getElementById("payUIClose");
         var btnNo = document.getElementById("btn-no");
         var kefu = document.getElementById("kefu");
         var personal_all = document.getElementById("personal_all");
         var family_all = document.getElementById("family_all");


         payUIClose.onclick=function (){
             $(".layer1").show()
         };
         btnNo.onclick=function (){
          window.external.CloseWnd('pay')
         };
         $(".btnclose").click(function(){
             $(".layer1").hide()
         });
         kefu.onclick=function (){
             window.external.JumpService('http://office.zhuazi.com/kefu.html');
             var detail=$(this).attr("data-log");
             tab('detail',true)

         };
         personal_all.onclick=function (){
             window.external.JumpDetails('http://test.officeplus.zhuazi.com/personal.html')
         };
         family_all.onclick=function (){
             window.external.JumpDetails('http://test.officeplus.zhuazi.com/family.html')
         };
         /*日志*/
         function tab(name,boolen){
             $.ajax({
                 type:'GET',
                 url:log+ name+'/'+ channel+'/'+ edition + '/'+sys+'/'+cpuid,
                 dataType: 'json',
                 async:boolen,
                 success:function(res) {
                     if(res.code==200){

                     }
                 },
                 error:function(err) {

                 }
             });
         }

         $(".detail_all").click(function (){
             var detail=$(this).attr("data-log");
             tab(detail,true)
         });
         $("#btn-no").click(function (){
             var detail=$(this).attr("data-log");
             tab(detail,false)
         });
document.oncontextmenu = function(){
    event.returnValue = false;
};
     </script>
</body>
</html>